package cn.hsa.xxx.placeOrder.dto;


import cn.hsa.xxx.api.dto.DiscountRulesDTO;
import cn.hsa.xxx.placeOrder.entity.DiscountRulesDO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

@Component
public class DiscountRulesDTOConverter {

    /**
     * Convert DiscountRulesDTO to DiscountRulesDO
     *
     * @param discountRulesDTO
     * @return
     */
    public DiscountRulesDO convertToDiscountRulesDO(DiscountRulesDTO discountRulesDTO) {
        if (discountRulesDTO == null) {
            return null;
        }
        DiscountRulesDO discountRulesDO = new DiscountRulesDO();

        //DiscountRulesDO.setId(DiscountRulesDTO.getId());
        //DiscountRulesDO.setName(DiscountRulesDTO.getName());
        //DiscountRulesDO.setSex(DiscountRulesDTO.getSex());
        //DiscountRulesDO.setAddr(DiscountRulesDTO.getAddr());

        //性能略差，但使用方便
        BeanUtils.copyProperties(discountRulesDTO, discountRulesDO);

        return discountRulesDO;
    }

    /**
     * Convert DiscountRulesDO to DiscountRulesDTO
     *
     * @param discountRulesDO
     * @return
     */
    public DiscountRulesDTO convertToDiscountRulesDTO(DiscountRulesDO discountRulesDO) {
        if (discountRulesDO == null) {
            return null;
        }

        DiscountRulesDTO discountRulesDTO = new DiscountRulesDTO();

        //DiscountRulesDTO.setId(DiscountRulesDO.getId());
        //DiscountRulesDTO.setName(DiscountRulesDO.getName());
        //DiscountRulesDTO.setSex(DiscountRulesDO.getSex());
        //DiscountRulesDTO.setAddr(DiscountRulesDO.getAddr());

        //性能略差，但使用方便
        BeanUtils.copyProperties(discountRulesDO, discountRulesDTO);

        return discountRulesDTO;
    }
}
